[NET] back: Refcount fixes to vif rate-limiting code.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Mon, 9 Oct 2006 16:08:18 +0000 (17:08 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Mon, 9 Oct 2006 16:08:18 +0000 (17:08 +0100)
Signed-off-by: Keir Fraser <keir@xensource.com>
linux-2.6-xen-sparse/drivers/xen/netback/interface.c
linux-2.6-xen-sparse/drivers/xen/netback/netback.c

index 5d122cf41bf83c313478ed0af21184bcf628c165..2785f4d895f1e537d9a2efa8bf2e4a3ebaaf8853 100644 (file)
@@ -62,6 +62,7 @@ static void __netif_down(netif_t *netif)
 {
        disable_irq(netif->irq);
        netif_deschedule_work(netif);
+       del_timer_sync(&netif->credit_timeout);
 }
 
 static int net_open(struct net_device *dev)
index a75a4c9bc2f52e768e1ec7f76e02b2d12bc69af5..49f6013d445db5fa41e82af35bce61097e1afdde 100644 (file)
@@ -1102,6 +1102,7 @@ static void net_tx_action(unsigned long unused)
                i = netif->tx.req_cons;
                rmb(); /* Ensure that we see the request before we copy it. */
                memcpy(&txreq, RING_GET_REQUEST(&netif->tx, i), sizeof(txreq));
+
                /* Credit-based scheduling. */
                if (txreq.size > netif->remaining_credit) {
                        unsigned long now = jiffies;
@@ -1110,8 +1111,10 @@ static void net_tx_action(unsigned long unused)
                                msecs_to_jiffies(netif->credit_usec / 1000);
 
                        /* Timer could already be pending in rare cases. */
-                       if (timer_pending(&netif->credit_timeout))
-                               break;
+                       if (timer_pending(&netif->credit_timeout)) {
+                               netif_put(netif);
+                               continue;
+                       }
 
                        /* Passed the point where we can replenish credit? */
                        if (time_after_eq(now, next_credit)) {
@@ -1128,7 +1131,8 @@ static void net_tx_action(unsigned long unused)
                                        tx_credit_callback;
                                __mod_timer(&netif->credit_timeout,
                                            next_credit);
-                               break;
+                               netif_put(netif);
+                               continue;
                        }
                }
                netif->remaining_credit -= txreq.size;